package top.xxyu.config;

import lombok.extern.java.Log;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*;

@RestController
@RequestMapping("/api")
@Log
public class Demo {

    @RequestMapping(value = "/getData")
    public String getData(Date pars) {
        log.info(String.valueOf(pars));
        return "hell222o";
    }


    @RequestMapping(value = "/saveForm")
    public String saveForm(@RequestBody Map data, HttpServletRequest request) throws IOException {
        log.info(data.toString());
        return Objects.toString(data.get("date"),"222222222");
    }

    @RequestMapping(value = "/getDataGrid")
    public List<Map<String, Object>> getDataGrid(HttpServletRequest request) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (int i = 0; i < 100 ; i++) {
            HashMap<String, Object> result = new HashMap<>();
            result.put("name","小王");
            result.put("email","xiaosan@qq.com");
            result.put("createTime",new Date().getTime());
            list.add(result);
        }


        return list;
    }
}
